package com.woniu.uums.controller;

import com.woniu.common.dto.RegisterDto;
import com.woniu.common.dto.ZyManageDto;
import com.woniu.common.utils.GetManageUserNickName;
import com.woniu.common.utils.ResponseData;
import com.woniu.common.utils.ResponseEnum;
import com.woniu.common.utils.SMSUtils;
import com.woniu.uums.service.ZyManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UumsController {
    @Autowired
    private ZyManageService zyManageService;

    /**
     * 登录
     * @param registerDto
     * @return
     */
    @PostMapping("/login")
    public ResponseData<?> login(@RequestBody RegisterDto registerDto) {
        return zyManageService.login(registerDto);
    }
    /**
     * 注册
     * @param registerDto
     * @return
     */
    @PostMapping("/register")
    public ResponseData<?> register(@RequestBody RegisterDto registerDto) {

        return zyManageService.register(registerDto);
    }
    @GetMapping("/token")
    public ResponseData<?> token() {
        return new ResponseData().success();
    }
    @GetMapping("/nameByLogin")
    public ResponseData<?> nameByLogin(){
        String userName = null;
        try {
            userName = GetManageUserNickName.getUserName();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return new ResponseData().success(userName);
    }
}